import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testCase = "DBshop007查看发货单"

# 调用函数打开指定网址,并且获取函数的返回值,函数返回的是浏览器的对象
driver = openBrowser(urlAdmin)
# 调用函数登录dbshop的后台
DBshopLoginAdmin(driver)
# 调用函数点击销售管理，发货单二级菜单
DBshopEnterMenu2(driver,'销售管理','发货单')


rootPath = get_pro_rootpath() #获取项目的绝对路径
filePath = rootPath+r'\public\order1.txt' #拼接文件路径
orderNo = readFile(filePath) #读取文件中的订单编号

# 轴定位元素，定位订单号后面的查看下面的a标签，点击
driver.find_element_by_xpath("//td[text()='%s']/following-sibling::td[5]/a"%orderNo).click()
# 等待
time.sleep(4)

s = driver.find_element_by_xpath("//body").text
l = "订单号"+orderNo+"  "
r = "\)"

order_State = reGetString(s,l,r)

yuqi = "已收货"  # 预期值

if yuqi == order_State:
    writeLog("%s 测试通过" % testCase)
else:
    writeLog("%s 测试不通过" % testCase)
    getPhoto(driver)
driver.quit()